﻿<Window x:Class="WpfGenetic.SettingsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfGenetic"
        mc:Ignorable="d"
        Title="Настойки" Height="750" Width="750" Icon="Resources/settings.ico"
        SizeToContent="WidthAndHeight">

    <Window.Resources>
        <ControlTemplate x:Key="TextBoxValidationErrorTemplate">
            <StackPanel Orientation="Horizontal">
                <Border BorderBrush="IndianRed" BorderThickness="2">
                    <AdornedElementPlaceholder />
                </Border>
                <TextBlock Foreground="Red" FontWeight="Bold" >!</TextBlock>
            </StackPanel>
        </ControlTemplate>
        
        <Style x:Key="TextBlockDefault" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="Lucida Console" />
            <Setter Property="Margin" Value="5" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="HorizontalAlignment" Value="Left"/>
        </Style>
        
        <Style x:Key="TextBoxDefault" TargetType="TextBox">
            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource TextBoxValidationErrorTemplate}"/>
            <Setter Property="Margin" Value="5" />
            <Setter Property="Width" Value="75" />
            <Setter Property="HorizontalAlignment" Value="Right"/>
        </Style>

        <Style x:Key="CheckBoxDefault" TargetType="CheckBox">
            <Setter Property="Margin" Value="5" />
            <Setter Property="HorizontalAlignment" Value="Right"/>
            <Setter Property="IsThreeState" Value="False"/>
            <Setter Property="IsChecked" Value="False"/>
        </Style>
    </Window.Resources>

    <Grid Name="grid_Main">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <Menu Grid.Row="0" Grid.ColumnSpan="2" Height="25" VerticalAlignment="Top">
            <MenuItem Header="Дополнительно">
                <MenuItem Name="loadDefaultConfig" Header="Загрузить конфигурацию по умолчанию" 
                          Click="LoadDefaultConfig_Click"></MenuItem>
                
                <MenuItem Name="loadStartingConfig" Header="Загрузить стартовую конфигурацию" 
                          Click="LoadStartingConfig_Click"></MenuItem>
                <Separator />
                <MenuItem Name="saveStartingConfig" Header="Сохранить конфигурацию как стартовую" 
                          Click="SaveStartingConfig_Click"></MenuItem>
            </MenuItem>
            <MenuItem Name="helpMenu" Header="Помощь" Click="HelpMenu_Click"></MenuItem>
        </Menu>
        
        <!-- Левый столбец: -->
        <StackPanel Name="leftStack"  Margin="10" Grid.Row="1" Grid.Column="0"
                    VerticalAlignment="Center" HorizontalAlignment="Center">

            <!-- Информационные настройки: -->
            <TextBlock Style="{StaticResource TextBlockDefault}" >Информационные настройки:</TextBlock>
            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >POPULATION_SIZE:</TextBlock>
                <TextBox Name="tBox_POPULATION_SIZE" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="POPULATION_SIZE">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>
            
            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" > MAX_REPETITION_OF_INDIVIDUALS: </TextBlock>
                <TextBox Name="tBox_MAX_REPETITION_OF_INDIVIDUALS" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="MAX_REPETITION_OF_INDIVIDUALS">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >MAX_GENERATIONS:</TextBlock>
                <TextBox Name="tBox_MAX_GENERATIONS" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="MAX_GENERATIONS">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >CONSOLE_WRITTEN_COUNT:</TextBlock>
                <TextBox Name="tBox_CONSOLE_WRITTEN_COUNT" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="CONSOLE_WRITTEN_COUNT">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >COUNT_OF_MAX_SAVE:</TextBlock>
                <TextBox Name="tBox_COUNT_OF_MAX_SAVE" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="COUNT_OF_MAX_SAVE">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <!-- Настройки характеристик ключей: -->
            <TextBlock Style="{StaticResource TextBlockDefault}" ><LineBreak/>Настройки характеристик ключей:</TextBlock>
            <!-- Характеристики ключа шифра Виженера: -->
            <DockPanel Name="dp_MIN_START_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >MIN_START_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_MIN_START_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="MIN_START_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel Name="dp_MAX_START_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >MAX_START_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_MAX_START_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="MAX_START_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel Name="dp_RANK_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >RANK_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_RANK_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="RANK_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <!-- Характеристики ключей Перестановочного Шифра: -->
            <DockPanel Name="dp_HORIZONTAL_MIN_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >HORIZONTAL_MIN_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_HORIZONTAL_MIN_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="HORIZONTAL_MIN_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel Name="dp_HORIZONTAL_MAX_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >HORIZONTAL_MAX_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_HORIZONTAL_MAX_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="HORIZONTAL_MAX_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel Name="dp_RANK_HORIZONTAL_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >RANK_HORIZONTAL_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_RANK_HORIZONTAL_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="RANK_HORIZONTAL_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>
            
            <DockPanel Name="dp_VERTICAL_MIN_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >VERTICAL_MIN_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_VERTICAL_MIN_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="VERTICAL_MIN_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel Name="dp_VERTICAL_MAX_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >VERTICAL_MAX_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_VERTICAL_MAX_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="VERTICAL_MAX_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel Name="dp_RANK_VERTICAL_KEY_LENGTH">
                <TextBlock Style="{StaticResource TextBlockDefault}" >RANK_VERTICAL_KEY_LENGTH:</TextBlock>
                <TextBox Name="tBox_RANK_VERTICAL_KEY_LENGTH" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="RANK_VERTICAL_KEY_LENGTH">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <!-- Настройки фитнесс-функции: -->
            <TextBlock Style="{StaticResource TextBlockDefault}" ><LineBreak/>Настройки фитнесс-функции:</TextBlock>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >BIGRAMS_TYPE:</TextBlock>
                <CheckBox x:Name="checkBox_BIGRAMS_TYPE" Style="{StaticResource CheckBoxDefault}" DockPanel.Dock="Right"
                          Checked="CheckBox_BIGRAMS_TYPE_Checked" Unchecked="CheckBox_BIGRAMS_TYPE_Unchecked"/>
                <TextBox Name="tBox_BIGRAMS_TYPE" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="BIGRAMS_TYPE">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >TRIGRAMS_TYPE:</TextBlock>
                <CheckBox x:Name="checkBox_TRIGRAMS_TYPE" Style="{StaticResource CheckBoxDefault}" DockPanel.Dock="Right"
                          Checked="CheckBox_TRIGRAMS_TYPE_Checked" Unchecked="CheckBox_TRIGRAMS_TYPE_Unchecked"/>
                <TextBox Name="tBox_TRIGRAMS_TYPE" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="TRIGRAMS_TYPE">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel Name="dp_INDEX_OF_MATCHES_FLAG">
                <TextBlock Style="{StaticResource TextBlockDefault}" >INDEX_OF_MATCHES_FLAG:</TextBlock>
                <CheckBox x:Name="checkBox_INDEX_OF_MATCHES_FLAG" Style="{StaticResource CheckBoxDefault}"
                          Checked="CheckBox_INDEX_OF_MATCHES_FLAG_Checked" Unchecked="CheckBox_INDEX_OF_MATCHES_FLAG_Unchecked"/>
            </DockPanel>

        </StackPanel>

        <!-- Правый столбец: -->
        <StackPanel Name="rightStack"  Margin="10" Grid.Row="1" Grid.Column="1"
                    VerticalAlignment="Center" HorizontalAlignment="Center">

            <!-- Настройки отбора: -->
            <TextBlock Style="{StaticResource TextBlockDefault}" >Настройки отбора:</TextBlock>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >SIZE_TOURNAMENT:</TextBlock>
                <TextBox Name="tBox_SIZE_TOURNAMENT" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="SIZE_TOURNAMENT">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>
            
            <!-- Настройки скрещивания: -->
            <TextBlock Style="{StaticResource TextBlockDefault}" ><LineBreak/>Настройки скрещивания:</TextBlock>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >P_CROSSOVER:</TextBlock>
                <TextBox Name="tBox_P_CROSSOVER" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="P_CROSSOVER">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >P_KEY_CROSSOVER:</TextBlock>
                <TextBox Name="tBox_P_KEY_CROSSOVER" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="P_KEY_CROSSOVER">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <!-- Настройки мутации: -->
            <TextBlock Style="{StaticResource TextBlockDefault}" ><LineBreak/>Настройки мутации:</TextBlock>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >P_MUTATION:</TextBlock>
                <TextBox Name="tBox_P_MUTATION" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="P_MUTATION">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >P_KEY_MUTATION:</TextBlock>
                <TextBox Name="tBox_P_KEY_MUTATION" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="P_KEY_MUTATION">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >P_LENGTH_MUTATION:</TextBlock>
                <TextBox Name="tBox_P_LENGTH_MUTATION" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="P_LENGTH_MUTATION">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >P_RAISE_MUTATION:</TextBlock>
                <TextBox Name="tBox_P_RAISE_MUTATION" Style="{StaticResource TextBoxDefault}">
                    <TextBox.Text>
                        <Binding Path="P_RAISE_MUTATION">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </DockPanel>

            <!-- Алфавиты: -->
            <TextBlock Style="{StaticResource TextBlockDefault}" ><LineBreak/>Основной алфавит:</TextBlock>
            <Grid>
                <TextBox Name="tBox_Alphabet">
                    <TextBox.Text>
                        <Binding Path="Alphabet">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </Grid>

            <DockPanel>
                <TextBlock Style="{StaticResource TextBlockDefault}" >Дополнительный алфавит:</TextBlock>
                <CheckBox x:Name="checkBox_AlphabetSpecial" Style="{StaticResource CheckBoxDefault}"
                          Checked="CheckBox_AlphabetSpecial_Checked" Unchecked="CheckBox_AlphabetSpecial_Unchecked"/>
            </DockPanel>

            <Grid>
                <TextBox Name="tBox_AlphabetSpecial">
                    <TextBox.Text>
                        <Binding Path="AlphabetSpecial">
                            <Binding.ValidationRules>
                                <DataErrorValidationRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
            </Grid>

        </StackPanel>

        <WrapPanel Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10">
            <Button IsDefault="True" MinWidth="60" Margin="5" Name="bt_SetConf"
                    Click="Bt_SetConf_Click">
                Установить
            </Button>
            <Button IsCancel="True" MinWidth="60" Margin="5">Отмена</Button>
        </WrapPanel>
        
    </Grid>
</Window>
